package ain.impr;

import environment.Pitch;
import environment.player.Player;

public class ImprTrackAntibody extends ImprAbstractAntibody
{
	private static int ID = 4;
	
	public ImprTrackAntibody(Player player, Pitch pitch)
	{
		super(player, pitch);
	}
	
	public void execute()
	{
		// do nothing?	
	}
	
	protected double teamDistBallRatio(double ratio)
	{
		double random = Math.random() * (1.0/3.0);
		
		if (ratio < 1 -random)
		{
			return 0;
		}
		else if (ratio >= 2)
		{
			return 1;
		}
		else
		{
			return ratio / (1 + random);
		}
	}
	
	protected double opntDistBallRatio(double ratio)
	{
		double random = Math.random() * (1.0/3.0);
		
		if (ratio < 1 -random)
		{
			return 0;
		}
		else if (ratio >= 2)
		{
			return 1;
		}
		else
		{
			return ratio / (1 + random);
		}
	}
	
	protected double distBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= ((1.0/3.0) * 5))
		{
			return 0;
		}
		else if (zoneNumber <= ((2.0 / 3) * 5))
		{
			return (zoneNumber - ((1.0 / 3) * 5)) / ((1.0 / 3) * 5);
		}
		else if (zoneNumber <= 5)
		{
			if ((1 - ((zoneNumber - ((2.0/3) * 5)) / ((1.0/3) * 5))) < 0) return 0;
			return 1 - ((zoneNumber - ((2.0/3) * 5)) / ((1.0/3) * 5));
		}
		
		else return 0;
	}
	
	protected double imprBallGoalValue(double zoneNumber)
	{
		if (zoneNumber <= 1 + (4.0/3.0))
		{
			return 0;
		}
		if (zoneNumber <= 1 + (8.0/3.0))
		{
			return (zoneNumber - (1 + (4.0/3.0))) / (4.0/3.0);
		}
		else
		{
			if ((1 - ((zoneNumber - (1 + (8.0/3.0))) / (4.0/3.0))) < 0) return 0;
			return 1 - ((zoneNumber - (1 + (8.0/3.0))) / (4.0/3.0));
		}
	}
	
	protected double distBallPlayerValue(double distance)
	{
		if (distance <= FAR_RADIUS)
		{
			return distance / FAR_RADIUS;
		}
		else return 1;
	}
	
	public int getID()
	{
		return ID;
	}
	
	public String toString()
	{
		return "Track";
	}
}
